#-------------------------------------------------------------------------------
# Name:        ChangeLAAnalysisProperties
# Purpose:     Access a location-allocation Network Analyst layer, and change
#	           various properties.
#
# Author:      Esri
#
# Created:     29/02/2012
# Copyright:   (c) Esri 2012
#-------------------------------------------------------------------------------

import arcpy
from datetime import datetime

def main():
    arcpy.env.overwriteOutput = True

    #Get the Network Analyst layer object and the date/time value from the
    # user interface.
    naLayer = arcpy.GetParameter(0)
    travelFrom = arcpy.GetParameter(1)
    numberOfFacilitiesToFind = arcpy.GetParameter(2)
    defaultCapacity = arcpy.GetParameter(3)
    datehour = arcpy.GetParameter(4)

    #Set the property values to match those entered by the user.
    naLayerProps = arcpy.na.GetSolverProperties(naLayer)
    naLayerProps.travelDirection = travelFrom
    naLayerProps.defaultCapacity = defaultCapacity
    naLayerProps.facilitiesToFind = numberOfFacilitiesToFind
    naLayerProps.timeOfDay = datehour

    #Return the updated Network Analyst layer.
    arcpy.SetParameter(5, naLayer)

if __name__ == '__main__':
    main()
